home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doSubdivToNurbs.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.2 KB  |  130 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Description:
  21. //      Functions called from "Subdiv to NURBS conversion".
  22. //
  23.  
  24. //
  25. //  Procedure Name:
  26. //      doSubdivToNurbs
  27. //
  28. //  Description:
  29. //        This is the actual function that gets called from "Subdiv to NURBS" 
  30. //      option box.
  31. //
  32. //  Input Arguments:
  33. //      None.
  34. //
  35. //  Return Value:
  36. //      None.
  37. //
  38. //  Note:
  39. //
  40. global proc int doSubdivToNurbs( string $args[] )
  41. {
  42.     int $status = 0;
  43.  
  44.     if( size($args) < 1 ) {
  45.         error("Incorrect doSubdivToNurbs \"1\" number of arguments.");
  46.         return $status;
  47.     }
  48.  
  49.     global int $gSelectSubdivSurface;
  50.  
  51.     // convert all subd's
  52.     string $list[] = `filterExpand -ex 1 -fp 1 -sm $gSelectSubdivSurface`; 
  53.     int $len = size($list);
  54.  
  55.     if ($len == 0) {
  56.         error ("Select a subdivision surface " +
  57.                "which you want to convert.");
  58.         return $status;
  59.     }
  60.  
  61.     int $globalHist = $args[0];
  62.     int $origObjectAction = $args[1];
  63.     int $outputType = $args[2];
  64.  
  65.     string $cmd = "subdToNurbs";
  66.  
  67.     switch ($origObjectAction) {
  68.       case 1:
  69.         // replace original object, forces history off, but delete
  70.         // will take care of that...
  71.         $cmd = $cmd + " -ch off -aut on ";
  72.         break;
  73.  
  74.       case 2:
  75.         // hide original object, forces history on
  76.         $cmd = $cmd + " -ch on -aut on ";
  77.         if( !$globalHist ) {
  78.             warning( "Forcing construction history to on." );
  79.         }
  80.         break;
  81.  
  82.       case 3:
  83.       default:
  84.         // show original object, respects global construction history
  85.         $cmd = $cmd + " -ch " + $globalHist + " -aut on";
  86.         break;
  87.     }
  88.  
  89.     // output type
  90.     $cmd = $cmd + " -ot " + $outputType + " ";
  91.  
  92.     //  Convert each subdiv, one at a time so we can catch errors
  93.     //
  94.       string $nurbsRes[];
  95.     string $selList = "";
  96.  
  97.     for($i = 0; $i < $len; $i++) {
  98.         int $vis = `getAttr  ($list[$i] + ".visibility")`;
  99.         if (!$vis) continue;
  100.         $retVal = catch ($nurbsRes = evalEcho ($cmd + $list[$i]));
  101.  
  102.         // if there's no error, do post work and add results 
  103.         if ($retVal != 1){
  104.             switch ($origObjectAction){
  105.               case 1:
  106.                 evalEcho ("delete "  + $list[$i]);
  107.                 break;
  108.               case 2:
  109.                 evalEcho ("hide " + $list[$i]);      
  110.                 break;
  111.               default:
  112.                 break;
  113.             }
  114.  
  115.             for ($s in $nurbsRes) {
  116.                 $selList += ($s + " ");
  117.             }
  118.         }
  119.     }
  120.  
  121.     if (size($selList) > 0){
  122.           $selList += ";";
  123.         eval ("select -r " + $selList);
  124.     }
  125.  
  126.     return $status;
  127. }
  128.  
  129.  
  130.